home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 1 / ACE CD 1.iso / files / docs / devpac2d.lha / DevpacV2Part2.doc < prev    next >
Encoding:
Text File  |  1994-11-27  |  68.2 KB  |  1,627 lines

  1.                         DEVPAC 2 PART 2
  2.  
  3. See part one for who did what. PARASITE
  4.  
  5.  
  6. CHAPTER 4: SYMBOLIC DEBUGGER
  7.  
  8. INTRODUCTION
  9.      Programs written in assembly language are particularly error-
  10. prone  because  even a slight mistake can result  in  the  entire
  11. machine crashing.  There are various forms of bugs,  ranging from
  12. the trivial (e.g.  a missing CR in a printout),  though the usual
  13. (e.g.  an incorrect result_ to the very serious (e.g. the machine
  14. completely hanging, perhaps with a weird display).
  15.      To help you find and correct all forms of bugs, Devpac includes
  16. MonAm.  MonST is a symbolic debugger and disassembler which  lets
  17. you examine programs and memory,  execute programs an instruction
  18. at  a  time and trap processor exceptions  caused  by  programmer
  19. error. As MonAm is symbolic you can look at your program complete
  20. with all the original labels,  making debugging very much  easier
  21. than having to battle with 6-digit hex numbers (or 8 digits on the
  22. 68020!).
  23.      Although MonAm is a low-level debugger, displaying such things as
  24. 68000 instructions and bytes of memory,  it can also be used  for
  25. debugging  programs  written  with any  compiler  that  generates
  26. machine-code output.  If the compiler has the option to dump  the
  27. symbols into the binary code then you will see your procedure and
  28. function  names  within  the code,  and you can  even  view  your
  29. original  source  code.
  30.      As MonAm uses its own screen (in the Amiga sense), if you are
  31. debugging a program with windows your program will not be sent re-draw
  32. messages whilst you are using the debugger. Many other Amiga debuggers
  33. do send these messages - it can be very confusing.
  34.  
  35. EXCEPTIONS
  36.      MonAm uses the 68000 processor exceptions to stop runaway
  37. programs and to single-step,  so at this point it would be useful
  38. to  explain them and what normally happens when they occur on  an
  39. Amiga.
  40.      There are various types of exception that can  occur,  some
  41. deliberately,  others  accidentally.  When  one  does  occur  the
  42. processor saves some information on the SSP, goes into Supervisor
  43. mode and jumps to an exception handler. On the Amiga these normally
  44. produce a software error tash held system requester, or the dreaded
  45. guru, but when MonAM is active it re-directs  some of these exceptions
  46. so it can take control  when they occur. The various forms of
  47. exceptions, their usual results, and  what happens when they occur
  48. with MonAm active is  shown  in the following table:
  49.  
  50.   No.   EXCEPTION              MONAM ACTIVE
  51.    2    bus error              trapped
  52.    3    address error          trapped
  53.    4    illegal instruction    trapped
  54.    5    zero divide            trapped
  55.    6    CHK instruction        trapped
  56.    7    TRAPV instruction      trapped
  57.    8    privilege violation    trapped
  58.    9    trace                  single stepping
  59.   10    line 1010 emulator     trapped
  60.   11    line 1111 emulator     trapped
  61.   32    trap #0 to #15         trapped
  62.  
  63.     The exact causes of the above exceptions (and how best to recover
  64. from  them)  are  detailed at the end of  this  section,  but  to
  65. summarise:
  66.  
  67. Exceptions  2  to  8 are caused by a  programmer  error  and  are
  68. trapped by MonAM. Exception  9  can remotely be caused by programmer
  69. error  and  is used by MonAM for single stepping. The  rest  (i.e.
  70. Trap instructions) are  diverted  into MonAm,  but  can  subsequently
  71. be re-defined to be  exploited  by programs if required.
  72.       Occasionally  very  nasty crashes can cause the whole  screen
  73. to fill with colourful garbage, which looks very  impressive,  but
  74. is not very useful!
  75.  
  76. INVOKING MONAM
  77.      Monam is invoked by typing the command
  78.  
  79. monam2 (RETURN)
  80.  
  81.      This can optionally be followed by a program name, and a command
  82. line to be passed to it. For example:
  83.  
  84. monam2 c:genam2 examples/demo.s (RETURN)
  85.  
  86. will cause Monam to be invoked, to in turn load genam, and pass a
  87. filename to it.
  88.      When Monam has loaded, the screen will display three windows in
  89. which all Monam information is displayed. Immidiatly after loading the
  90. prompt enter program name or press return: will appear. At this point
  91. you have to choose weather you are going to debug a particular
  92. program, or just have a look around memory.
  93.  
  94. DEBUGGING A PROGRAM
  95.      If you wish to debug a specific program, you should enter it's
  96. filename including drive and directory if required and Manam will try
  97. and load the program. If it fails, it will display:
  98.  
  99. AmigaDOS error xxx
  100.  
  101. and you can use the (CTRL)-L command to try again.
  102.      Assuming the filename is valid, monam will load it. it will also
  103. check for any symbols within a file. After a succesful load, the
  104. prompt enter command line: will appear and you may type in a command
  105. line thet will be passed to the program being debugged in the standard
  106. way. If you don't want a command line, press return alone. The message
  107.  
  108. Exception:Breakpoint
  109.  
  110. will appear together with the front panel display. It says Breakpoint
  111. because Monam places a breakpoint at the first instruction of the
  112. program then executes it.
  113.  
  114. MONAM & MULTI-TASKING
  115.      the Amiga is a multi-tasking machine, and this imposes some
  116. restrictions on what monam can do. Having loaded a program (or task)
  117. into it, that task is suspended. This means it is waiting, in this
  118. case for a Monam command to let it continue. The other state the task
  119. can be in is executing - that is it is running at the same time. Some
  120. commands require one of these states to operate - for example you can
  121. only single-step a task that is suspended. if it is running you will
  122. get the error 'Task must be suspended!' when you try.
  123.  
  124. EXAMINING MEMORY
  125.     If you are just interested in looking at memory, press (RETURN)
  126. and you will see the front panel display, and get the command:
  127.  
  128. prompt.
  129.  
  130. SYMBOLIC DEBUGGING
  131.      A major feature of MonAm is its ability to use symbols taken from
  132. the original program whilst debugging. MonAm uses standard AmigaDOS
  133. file SYMBOL hunks as produced by most Amiga programs that produce
  134. executable files, such as linkers, compilers and GenAm.
  135.  
  136. MONAM DIALOGUE AND ALERT BOXES
  137.      MonAm makes extensive use of dialogue and alert-boxes which
  138. are similar in concept to those in intuition programs but have several
  139. differances.
  140.      A Monam dialogue box displays the prompt ESC to abort above  the
  141. top  left  corner of the box together  with  a  prompt,  normally
  142. followed  by a blank line with a cursor.  At any time a  dialogue
  143. box  may be aborted by pressing Esc,  or data may be  entered  by
  144. typing.  The cursor keys,  Backspace and Del keys may be used  to
  145. edit  entered  text in the usual way and the whole  line  may  be
  146. delted by pressing the (AMIGA)-X key combination.
  147.      An entered line is terminated by pressing  the  Return
  148. key, though if the line contains errors the screen will flash and
  149. the  Return key will be ignored allowing correction of  the  data
  150. before pressing Return again.
  151.      A MonAM alert box is a small box displaying a  message  together
  152. with the prompt (Return) and is normally used to inform the  user
  153. of  some form of error.  The box will disappear on  pressing  the
  154. Return or Esc keys, whichever is more convenient.
  155.  
  156. INITIAL DISPLAY
  157.      Unless  you  have chosen the Debug option within the  editor  you
  158. will be presented with a dialogue box prompting for an executable
  159. program name. If you wish to debug a program from disk you should
  160. enter the filename (which defaults to an extension of .PRG)  then
  161. press Return,  then you will be prompted for any command line. If
  162. you do not wish to debug a program from disk at this  stage,  for
  163. example  you  wish to investigate memory,  press the Esc  key  or
  164. enter a blank filename.
  165.  
  166. FRONT PANEL DISPLAY
  167.      The main display of MonAm is via a Front Panel showing registers,
  168. memory and instructions. The name Front Panel stems from the type
  169. of  panels that were mounted on mainframe and mini  computers  to
  170. provide  information on the state of the machine at a  particular
  171. moment,  usually through the use of flashing lights. These lights
  172. represent  whether  or  not  particular  flip-flops   (electronic
  173. switches) within the computer are open or closed;  the flip-flops
  174. that are chosen to be shown on this panel are normally those that
  175. make  up  the internal registers and flags of the  computer  thus
  176. enabling  programmers and engineers to observe what the  computer
  177. is doing when running a program.
  178.      So these are hardware front panel displays; what MonAM provides
  179. you with is a software front panel - the code within MonAm works
  180. out the state of your computer and then displays this information
  181. on the screen.
  182.  
  183. The initial MonAm display consists of three windows:
  184.  
  185.      The top window (number 1) displays the values of the data and
  186. address registers, together with the memory pointed to by these
  187. registers.
  188.      The next  window  (number 2)  is the  disassembly  window  which
  189. displays several lines of instructions,  by default based  around
  190. the program counter (PC),  shown in the title area of the window.
  191. A => sign is used to denote the currant value of the PC
  192.      Window number 3 is the memory window which displays a section  of
  193. memory in word-aligned hex and ASCII.
  194.      One  of  the most powerful features of MonAm is  its  flexibility
  195. with  windows - up to 2 additional windows may  be  created,  the
  196. font  size  can  be  changed,  and  windows  may  be  locked  to
  197. particular registers, these features are detailed later.
  198.  
  199. SIMPLE WINDOW HANDLING
  200.      MonAm has the concept of a current window - this is  denoted  by
  201. displaying its title in black.  The current window may be changed
  202. by pressing the Tab key to cycle between them, or by pressing the
  203. (AMIGA) key together  with the window  number, for example (AMIGA)-2
  204. selects  the disassembly window.
  205.      NOTE: If your typing seems to be ignored in MonAm don't be
  206. alarmed, it means that another window is active, such as your
  207. programs. To correct this clich on any part of the MonAm display. you
  208. can always tell when the monAm window is active because the mouse
  209. pointer will be bug shaped.
  210.  
  211. COMMAND INPUT
  212.      MonAm is controlled by single-key commands which creates a  very
  213. fast user-interface,  though this can take getting used to if you
  214. are  familiar with a line-oriented command interface  of  another
  215. debugger. Users of HiSoft Devpac on other machines will find many
  216. commands  are  identical,  particulary with the Spectrum  and  QL
  217. debuggers, though the window commands are unique to MonAm. The
  218. commands are almost identical to DEVPAC ST version 2.
  219.      In general the (AMIGA) key - when  used  in conjunction with
  220. other keys it it acts on the  current window.
  221.      Commands  may  be entered in either upper or  lower  case.  Those
  222. commands  whose  effects are potentially disastrous  require  the
  223. Ctrl  key to be pressed in addition to a command  key.  The  keys
  224. used  where  chosen to be easy to  remember,  wherever  possible.
  225. Commands  take  effect immediately - there is no  need  to  press
  226. Return  and  invalid commands are simply  ignored.  The  relevant
  227. sections  of  the  front panel display  are  updated  after  each
  228. command so any effects can be seen immediately.
  229.      MonAm is a powerful and sometimes complex program and we  realise
  230. that  it  is  unlikely  that many users  will  use  every  single
  231. command.  For  this reason the remainder of the MonST  manual  is
  232. divided into two sections - the former is an introduction to  the
  233. basic  commands  of  the program,  while the  latter  is  a  full
  234. reference section.  It is possible for new users and beginners to
  235. use the debugger effectively while having only read the Overview;
  236. don't be intimidated by the Reference section.
  237.  
  238. MONAM OVERVIEW
  239.      To start with you will need to load a program to debug;  if  you
  240. have  assembled a program to memory you can use the Debug  option
  241. of the assembler or linker.
  242.      The  most  common  command  in  MonAm is  probably  single-step,
  243. obtained  by  pressing  Ctrl-Z (or Ctrl-Y if  you  find  it  more
  244. convenient). This will execute the instruction at the PC, the one
  245. shown in the Register window and,  normally,  also in the  Disas
  246. sembly  window.  After executing it the debugger re-displays  the
  247. values  of the registers and memory displayed,  so you can  watch
  248. the processor execute your program, step by step. Single-stepping
  249. is  the  best  way of going through sections  of  code  that  are
  250. suspect  and  require deeper investigation,  but it is  also  the
  251. slowest  - you may only be interested in a section of  code  near
  252. the  end of your program which could take ages to get to  if  you
  253. have to single-step all the way. There is, of course, an answer.
  254.      A breakpoint is a special word placed into your program to  stop
  255. it  running and enter MonST.  There are many types of  breakpoint
  256. but  we  will  restrict ourselves to  the  simplest  for  now.  A
  257. breakpoint  may  be  set by pressing (AMIGA)-B,  then  entering  the
  258. address you wish to place the breakpoint. You can enter addresses
  259. in MonSt in hex (the default base),  as a symbol, or as a complex
  260. expression.  Examples of a valid address are  1A2B0,  prog_start,
  261. 10+mydata.  If  you  type in an invalid address the  screen  will
  262. flash and allow you to correct the expression.
  263.      Having set a breakpoint you need some way of letting your program
  264. actually  run,  and  Ctrl-R will do this.  If will  execute  your
  265. program  using the registers displayed and starting from the  PC.
  266. MonST will be re-entered if a breakpoint has been hit,  or if  an
  267. exception occurs.
  268.      MonAm uses its own screen display which is independent from  your
  269. own  programs.  If you press the v key you will see your  current
  270. programs  display,  pressing  another key switches  you  back  to
  271. MonST. This allows you to debug programs without disturbing their
  272. output at all.
  273.      MonAm uses its own windows to,  and any window may be zoomed  to
  274. the  full screen size by pressing (AMIGA)-Z.  To return to  the  main
  275. display press (AMIGA)-Z or the Esc key.  The Esc key is also the best
  276. way of getting out of anything you may have invoked by  accident.
  277. The Zoom command,  like all (AMIGA)- commands,  works on the  current
  278. window  which you can change by pressing Tab.  You can  dump  the
  279. current window to your printer by pressing (AMIGA)-P.
  280.      To change the address from which a window  displays  its  data,
  281. press (AMIGA)-A,   then  enter  the  new  address.   Note  that  the
  282. disassembly  window will always re-display from the PC after  you
  283. single-step,  because  it  is locked to the PC.  The  locking  of
  284. windows is detailed in the Reference section.
  285.      To quit MonAm press Ctrl-C. This returns Monam directly to the
  286. CLI. If the task you are debugging is still running or suspended when
  287. you try and quit, you will be warned. If Monam terminates while the
  288. task under investigationis running, the machine will crash if any
  289. execption occurs subsiquently. A safer way is to use the ctrl-Q
  290. command to stop the task first. If you used the Debug option from the
  291. editor then  Ctrl-C will always terminate MonAm as well as your
  292. program.
  293.       We  hope this overview has given you a good idea  of  the  most
  294. common  features  of  MonST to let you get on  with  the  complex
  295. process of writing and debugging assembly language programs. When
  296. you  feel  more confident you should try and read  the  Reference
  297. section, probably best taken, like all medicine, in small doses.
  298.  
  299. MONAM REFERENCE
  300.  
  301. NUMERIC EXPRESSIONS
  302.      MonAm has a full expression evaluator,  based on that in  GenST,
  303. including operator precedence.  The main differences are that the
  304. default  base  is hexadecimal (decimal may be denoted  with  a  \
  305. sign),  there is no concept of types of expressions (relative  or
  306. absolute), ΓΈ  is used only for multiplication and there is a not-
  307. equals operator, <>.
  308.      Symbols may be referred to and are normally  case-sensitive  and
  309. significant  to either 8 or 22 characters (depending on the  form
  310. of debug used), though this can be changed with the MonAm Preferences
  311. command.
  312.      Registers  may be referred to simply by name, such as A3 or D7
  313. (case insensitive),  but this clashes with hex numbers. To obtain
  314. such  hex numbers precede them with either a leading zero or a  $
  315. sign. A7 refers to the user stack pointer.
  316.      There  are several reserved symbols which are  case  insensitive,
  317. namely CODE, SP, SR, and SSP. SP refers to either  the user- or
  318. supervisor-stack, depending on the current value of the status
  319. register. CODE refers to the first in the program. This is the same as
  320. HUNK1. The second hunk is HUNK2 and so on.
  321.      In addition there are 10 memories numbered M0 through  M9,  which
  322. are treated in a similar way to registers and can be assigned  to
  323. using  the Register Set command.  Memories 2 through 5  inclusive
  324. refer  to  the current start address of the relevant  window  and
  325. assigning to them will change the start address of that window.
  326.      The MonAm expression evaluator also supports  indirection  using
  327. the { and } symbols.  Indirection may be performed on a byte word
  328. or long basis, by following the } with a period then the required
  329. size,  which defaults to long.  If the pointer is invalid, either
  330. because the memory is unreadable or even (if the word or longword
  331. indirection is used) then the expression will not be valid.
  332.  
  333. For example, the expression:
  334.  
  335.        (data_start+10).w
  336.  
  337. will return the word contents of location data_start+10, assuming
  338. data_start is even. Indirection may be nested in a similar way to
  339. ordinary parenthesis.
  340.  
  341. WINDOW TYPES
  342.      There  are  four  window types and the exact  contents  of  these
  343. windows and how they are displayed is detailed below. The allowed
  344. types of windows is shown in the table below.
  345.  
  346. Window  Allowed Types
  347.   1     Register
  348.   2     Disassembly
  349.   3     Memory
  350.   4     Disassembly, Memory or Source-code
  351.   5     Memory
  352.  
  353. REGISTER WINDOW DISPLAY
  354.      The  data  registers are shown in hex,  together with  the  ASCII
  355. display  of  their low byte and then a hex display of  the  eight
  356. bytes  they point to in memory.  The address registers  are  also
  357. shown in hex,  together with a hex display of 12 bytes.  As  with
  358. all hex displays in MonAm this is word-aligned, with non-readable
  359. memory displayed as **.
  360.      The status  register  is  shown  in  hex  and  in  flag   form,
  361. additionally with U or S denoting user- or supervisor-modes.  A7'
  362. denotes the supervisor stack pointer,  displayed in a similar way
  363. to the other address registers.
  364.      The PC value is shown together with a disassembly of the  current
  365. instruction.  Where this involves one or more effective addresses
  366. these are shown in hex, together with a suitably-sized display of
  367. the memory they point to.
  368.  
  369. For example, the display
  370.  
  371.    TST.W $12A(A3)  ;00001FAE 0F01
  372.  
  373. signifies that the value of $12A plus register A3 is  $1FAE,  and
  374. that the word memory pointed to by this is $0F01.  A more complex
  375. example is the display
  376.  
  377.         MOVE.W $12A(A3),-(SP) ;00001FAE 0F01 =>002AC08 FFFF
  378.  
  379.      The source  addressing  mode is as before  but  the  destination
  380. address  is $2AC08,  presently containing $FFFF.  Note that  this
  381. display is always of a suitable size (MOVEM data being  displayed
  382. as a quad-word) and when pre-decrement addressing is used this is
  383. included in the address calculations.
  384.  
  385. DISASSEMBLY WINDOW DISPLAY
  386.      Disassembly  windows display memory as disassembled  instructions
  387. to the standard described below.  On the left the hex address  is
  388. shown,  followed by any symbol,  then the disassembly itself. The
  389. current value of the PC is denoted with >.
  390.      If the instruction has a breakpoint placed on it this  is  shown
  391. using  square brackets ([ ]) afterwards,  the contents  of  which
  392. depend on the type of breakpoint.  For stop breakpoints this will
  393. be the number of times left for this instruction to execute,  for
  394. conditional  breakpoints  this  will  be  a  ?  followed  by  the
  395. beginning  of the conditional expression,  for count  breakpoints
  396. this  will  be a = sign followed by the current  count,  and  for
  397. permanent breakpoints a symbol resembling a small zero in
  398. superscript is shown.
  399.      The exact format  of  the  disassembled  op-codes  is  Motorola
  400. standard,  as  GenAM accepts.  All output is  upper-case  (except
  401. lower-case  labels) and all numeric output is  hex,  except  Trap
  402. numbers. Leading zeroes are suppressed and the $ hex delimiter is
  403. not  shown on numbers less than 10.  Where relevant numerics  are
  404. shown  signed.
  405.      The only deviation from Motorola standard is  the
  406. register  lists  shown in MOVEM instructions - in order  to  save
  407. display  space  the  type of the second register in  a  range  is
  408. abbreviated, for example:
  409.  
  410.         MOVEM.L d0-d3/a0-a2,-(sp)
  411.  
  412. will be disassembled as:
  413.  
  414.         MOVEM.L d0-3/a0-2,-(sp)
  415.  
  416.     Certain library calls will be shown symbolically even if no symbol
  417. information was loaded with your program. The dissassembler is
  418. intelligent and recognises a MOVE into register a6 follower by a JSR
  419. using a6 and if it is recognised then will be displayed by name, for
  420. example:
  421.  
  422.         MOVE.L   4,a6
  423.         JSR      _LVOOpenLibrary(a6)
  424.  
  425.      It does this for the exec, graphics and intuition libraries,
  426. using the special file libs:libfile.monam. if this file is not found
  427. during Monams initialisation than such a dissassembly will not occur.
  428.  
  429. MEMORY WINDOW DISPLAY
  430.      Memory  windows  display  memory in the form of  a  hex  address,
  431. word-aligned hex display and ASCII.  Unreadable memory  locations
  432. are denoted by **.  The number  of  bytes shown is calculated  from
  433. the window width, up to a maximum of 16 bytes per line.
  434.  
  435. SOURCE-CODE WINDOW DISPLAY
  436.      The source code window displays ASCII files in a similar way to a
  437. screen  editor.  The default tab setting is 8 though this can  be
  438. toggled to 4 with the Edit Window command.
  439.  
  440. WINDOW COMMANDS
  441.     The (AMIGA) key is generally used for controlling windows,  and
  442. when used to apply to the current window. This is denoted by having an
  443. inverse title and can be changed by pressing the Tab or (AMIGA) plus
  444. the window number.
  445.      Most window commands work in any window,  zoomed or  not,  though
  446. when  it  does  not make sense to do  something  the  command  is
  447. ignored.
  448.  
  449. (AMIGA)-A                                             SET ADDRESS
  450. This sets the starting address of a memory or disassembly window.
  451.  
  452. (AMIGA)-B                                          SET BREAKPOINT
  453. Allows  the setting of any type of  breakpoint,  described  later.
  454.  
  455. (AMIGA)-E                                             EDIT WINDOW
  456. On a memory window this lets you edit memory in hex or ASCII. Hex
  457. editing can be accomplished using keys 1-9,  A-F,  together  with
  458. the cursor keys. Pressing Tab switches between hex & ASCII, ASCII
  459. editing takes each keypress and writes it to memory.  The  cursor
  460. keys can be used to move about memory.  To leave edit mode  press
  461. the Esc key.
  462.  
  463. On a register window this is the same as (AMIGA)-R, Register Set,
  464. described shortly.
  465.  
  466. On a source code window this toggles the tab setting  between  4
  467. and 8.
  468.  
  469. (AMIGA)-L                                            LOCK WINDOWS
  470. This  allows disassembly and register windows to be locked  to  a
  471. particular register. After any exception the start address of the
  472. window is re-calculated, depending on the locked register.
  473.      To  unlock simply enter a blank string. By default window 2 is
  474. locked  to  the  PC.  You  can lock  windows  to  each  other  by
  475. specifying a lock to a memory window, such as M2.
  476.  
  477. (AMIGA)-O                                              SHOW OTHER
  478. This  prompts for an expression and displays it in  hex,  decimal
  479. and as a symbol if relevant.
  480.  
  481. (AMIGA)-P                                            PRINTER DUMP
  482. Dumps the current window onto the printer.  It can be aborted  by
  483. pressing Esc.
  484.  
  485. (AMIGA)-R                                            REGISTER SET
  486. Allows  any  register to be set to a  value,  by  specifying  the
  487. register, an equals sign, then its new value. It can also be used
  488. to set the value of memories. For example the line:
  489.  
  490.            a3=a2+4
  491.  
  492. sets  register A3 to be A2 plus 4.  You can also use this to  set
  493. the  start address of windows when in zoom mode so that  on  exit
  494. from  zoom  mode  the  relevant window  starts  at  the  required
  495. address.
  496.  
  497. NOTE: Do not assign M4 if window 4 is currently  a  source-code
  498. window.
  499.  
  500. (AMIGA)-S                                           SPLIT WINDOWS
  501. This  either splits windows 2 into 2 and 4,  or splits  window  3
  502. into  3 and 5.  Each new window is independent from its  creator.
  503. Pressing (AMIGA)-S again will unsplit the window.
  504.  
  505. (AMIGA)-T                                             CHANGE TYPE
  506. This only works on window 4 (created either by splitting window 2
  507. or by loading a source file).  It changes the type of the  window
  508. between disassembly,  memory and source-code (if a file has  been
  509. loaded).
  510.  
  511. (AMIGA)-Z                                             ZOOM WINDOW
  512. This zooms the current window to be full size. Other Alt commands
  513. are  still available and normal size can be achieved by  pressing
  514. Esc or (AMIGA)-Z again.
  515.  
  516. NOTE: Zooming the register windows shows the values of the memoris M0
  517. to M9.
  518.  
  519. CURSOR KEYS
  520.      The cursor keys can be used on the current window,  the action of
  521. which depends on the window type.
  522.  
  523. On  a  memory  window all four cursor  keys  change  the  current
  524. address, and Shift Up Cursor and Shift Down Cursor move a page in
  525. either direction.
  526.  
  527. On  a  disassembly window Up Cursor and Down  Cursor  change  the
  528. start  address  on an instruction basis,  Left Cursor  and  Right
  529. Cursor change the address on a word basis.
  530.  
  531. On  a  source-code window Up Cursor and Down  Cursor  change  the
  532. display on a line basis and Shift Up Cursor and Shift Down Cursor
  533. on a page basis.
  534.  
  535. SCREEN SWITCHING
  536.      Monam uses  its  own  screen  display and will always make itself
  537. the front and active window whenever an exception (including
  538. breakpoints) occurs.
  539.  
  540. V                                               VIEW OTHER SCREEN
  541. This will put the monam screen to the back, normally showing your
  542. prograns screen Pressing any key will return the MonAm screen (so lang
  543. as you have not activated any other window).
  544.  
  545. BREAKPOINTS
  546.      Breakpoints  allow you to stop the execution of your  program  at
  547. specified points within it. MonST allows up to eight simultaneous
  548. breakpoints,  each  of  which may be one of five  types.  When  a
  549. breakpoint  is hit Monam is entered and then decides  whether  or
  550. not to halt execution of your program,  entering the front  panel
  551. display,  or continue,  this decision is based on the type of the
  552. breakpoint and the state of your program's variables.
  553.  
  554. SIMPLE BREAKPOINTS
  555.      These are one-off breakpoints which,  when executed,  are cleared
  556. and cause Monam to be entered.
  557.  
  558. STOP BREAKPOINTS
  559.      These are breakpoints that cause program execution to stop  after
  560. a particular instruction has been executed a particular number of
  561. times.  In  fact a simple breakpoint is really a stop  breakpoint
  562. with a count of one.
  563.  
  564. COUNT BREAKPOINTS
  565.      Merely counters; each time such a breakpoint is reached a counter
  566. associated with it is incremented, and the program will resume.
  567.  
  568. PERMANENT BREAKPOINTS
  569.      These  are  similar to simple breakpoints except  that  they  are
  570. never  cleared  -  every  time  execution  reaches  a   permanent
  571. breakpoint MonAm will be entered.
  572.  
  573. CONDITIONAL BREAKPOINTS
  574.       The most powerful type of breakpoint and  these  allow  program
  575. execution to stop at a particular address, only if an arbitrarily
  576. complex set of conditions apply.  Each conditional breakpoint has
  577. associated with it an expression (conforming to the rules already
  578. described).  Every time the breakpoint is reached this expression
  579. is evaluated,  and if it is non-zero (i.e. true) then the program
  580. will be stopped, otherwise it will resume.
  581.  
  582. (AMIGA)-B                                          SET BREAKPOINT
  583. This  is  a window command allowing the setting  or  clearing  of
  584. breakpoints  at any time.  The line entered should be one of  the
  585. following forms, depending on the type of breakpoint required:
  586.  
  587. <address>
  588. will set a simple breakpoint.
  589.  
  590. <address>,<expression>
  591. will  set a stop breakpoint at the given address,  after  it  has
  592. executed <expression> times.
  593.  
  594. <address>,=
  595. will set a count breakpoint.  The initial value of the count will
  596. be zero.
  597.  
  598. <address>,*
  599. will set a permanent breakpoint.
  600.  
  601. <address>,?<Expression>
  602. will set a conditional breakpoint, using the given expression.
  603.  
  604. <address>,-
  605. will clear any breakpoint at the given address.
  606.  
  607.      Breakpoints  cannot  be  set  on  addresses  which  are  odd   or
  608. unreadable,  or  in  ROM.
  609.      Every  time a breakpoint is reached,  regardless of  whether  the
  610. program  is  interrupted  or  resumed,   the  program  state   is
  611. remembered in the History buffer, described later.
  612.  
  613. HELP                                    SHOW HELP AND BREAKPOINTS
  614. This displays the current breakpoints, task status, its segment list
  615. (showing where the program is), free memory and the system memory
  616. list. (AMIGA) commands are available within this display. For UK A500
  617. 1.2 users (who cannot use the help key) this can also be obtained by
  618. pressing (AMIGA)-H
  619.  
  620. Ctrl-B                                             SET BREAKPOINT
  621. Included  mainly  for compatibility with MonAm 1,  this  sets  a
  622. simple breakpoint at the start address of the current window,  so
  623. long  as it is a disassembly window.  If a breakpoint is  already
  624. there then it will be cleared.
  625.  
  626. U                                                        GO UNTIL
  627. This prompts for an address, at which a simple breakpoint will be
  628. placed then program execution resumed.
  629.  
  630. Ctrl-K                                           KILL BREAKPOINTS
  631. This clears all set breakpoints.
  632.  
  633. Ctrl-A                                SET BREAKPOINT THEN EXECUTE
  634. A  command  that places a simple breakpoint  at  the  instruction
  635. after that at the PC and resumes execution from the PC.  This  is
  636. particularly  for DBF-type loops if you don't want to go  through
  637. the loop, but just want to see the result after the loop is over.
  638.  
  639. Ctrl-X                                     STOP PROGRAM EXECUTING
  640. This is a command to stop your task while it is executing. It does
  641. this by forcing the trace bit to be set, so you will get a trace
  642. exception. While this does work, be very careful if you stop it in th
  643. middle of some AmigaDOS ROM routines, particually signal handling and
  644. message passing.
  645.      NOTE: The above command accesses memory fields that are not
  646. guarenteed to remain the same for differant versions of the Amiga
  647. operating system. Initially you should try it at a time when nothing
  648. important is in the machine to check compatibility with the version of
  649. the operating system you are using before you are forced to use it
  650. when a task goes a little beserk. This command used to be Ctrl-S on
  651. MonAm version 1.
  652.  
  653. HISTORY
  654.      MonAm  has  a  history  buffer in which  the  machine  status  is
  655. remembered for later investigation.
  656.      The most common way of entering data into the history buffer  is
  657. when  you single-step,  but in addition every breakpoint  reached
  658. and  every  exception caused enters the machine  state  into  the
  659. buffer. Various forms of the Run command also cause entries to be
  660. made into this buffer.
  661.      NOTE:  The  history  buffer has room for five entries -  when  it
  662. fills  the  oldest entry is removed to make room for  the  newest
  663. entry.
  664.  
  665. H                                             SHOW HISTORY BUFFER
  666. This opens a large window displaying the contents of the  history
  667. buffer. All register values are shown including the PC as well as
  668. a disassembly of the next instruction to be executed.
  669.      NOTE: If a  disassembly  in the  History  display  includes  an
  670. instruction  which has a breakpoint placed on the [ ]s will  show
  671. the  current values for that breakpoint,  not the values  at  the
  672. time of the entry into the history buffer.
  673.  
  674. QUITTING MONAM
  675.  
  676. Ctrl-C                                                  TERMINATE
  677. This returns Monam directly to the CLi or to the editor if you invoked
  678. Monam from the editor. If the task you are debuggingis still running
  679. or suspended when you try and quit, you will be warned. If monam
  680. terminates while the task under investigation is running, the machine
  681. will crash if any exception occurs subsiquently. A safer way is to use
  682. the Ctrl-Q command to stop the task first.
  683.      If the Debug option has been used from the  GenAm editor  then
  684. MonAm will  terminate  automatically  when  the  program  it  is
  685. debugging has terminated.
  686.  
  687. CTRL-Q                                             QUIT A PROGRAM
  688. This is a way of forcing a task being debugged to Quit. This can be
  689. hazardous to use, and should only be done as a last resort. if your
  690. program is terminated in this way it will not clean up, and thus not
  691. de-allocate any memory it was using or close windows etc.
  692.  
  693.      NOTE: The above command accesses memory fields that are not
  694. guaranteed to remain the same for differant versions of the operating
  695. system. Initially you should try it at a time when nothing important
  696. is in th machine to check compatability with the version of the
  697. operating system you are using before you are forced to use it when a
  698. task goes a little beserk.
  699.  
  700. LOADING & SAVING
  701.  
  702. Ctrl-L                                    LOAD EXECUTABLE PROGRAM
  703. This  will prompt for an executable filename then a command  line
  704. and will attempt to load the file ready for execution.  If  MonAm
  705. has  already loaded a program it is not possible to load  another
  706. until the former has terminated.
  707.      The file to be loaded must be an executable file. use the load
  708. binary file command if you wish to edit other file types.
  709.      NOTE: This command in not available if Monam has been invoked
  710. using Debug from the editor.
  711.  
  712. B                                                LOAD BINARY FILE
  713. This  will  prompt  for  a filename  and  optional  load  address
  714. (separated  by  a  comma)  and will  then  load  the  file  where
  715. specified.  If  no  load  address is given then  memory  will  be
  716. allocated  from  the system and used.  M0 will be set  to  the  start
  717. address and M1 to the end address.
  718.  
  719. S                                                SAVE BINARY FILE
  720. This  will  prompt  for  a  filename,  a  start  address  and  an
  721. (inclusive) end address.  To re-save a file recently loaded  with
  722. the above command <filename>,M0,M1 may be specified,  assuming of
  723. course that M0 and M1 may be specified,  assuming of course  that
  724. M0 and M1 have not been re-assigned.
  725.  
  726. A                                                 LOAD ASCII FILE
  727. This  powerful command allows an ASCII file,  normally of  source
  728. code,  to  be loaded and viewed within Monam,  Window 4  will  be
  729. created if required then set up as a source code  window.  Memory
  730. for  the  source  code is taken from the system so sufficient free
  731. memory must be available.
  732.  
  733. EXECUTING PROGRAMS
  734.  
  735. Ctrl-R                                    RETURN TO PROGRAM / RUN
  736. This  runs the current program with the given register values  at
  737. full speed and is the normal way to resume execution after  entry
  738. via a breakpoint.
  739.  
  740. Ctrl-Z                                                SINGLE-STEP
  741. This  single-steps  the instruction at the PC  with  the  current
  742. register values.  Single-stepping a Trap, Line-A or Line-F opcode
  743. will, by default, be treated as a single instruction. This can be
  744. changed using Preferences.
  745.  
  746. Ctrl-Y                                                SINGLE-STEP
  747. Identical  to  Ctrl-Z above but included for the  convenience  of
  748. German users.
  749.  
  750. Ctrl-T                           INTERPRET AN INSTRUCTION (TRACE)
  751. This  interprets  the instruction at the PC using  the  displayed
  752. register  values.  It is similar to Ctrl-Z but skips  over  BSRs,
  753. JSRs, Traps, Line-A and Line-F calls, re-entering the debugger on
  754. return from them to save stepping all the way through the routine
  755. or trap it works on instructions in ROM or RAM.
  756.  
  757. Ctrl-S                                        SKIP AN INSTRUCTION
  758. Ctrl-s increments the PC register by the size of the current
  759. instruction thus causing it to be skipped. Use this instead of Ctrl-Z
  760. when you know that this instruction is going to do something it
  761. shouldn't.
  762.  
  763. R                                                   RUN (VARIOUS)
  764. This is a general Run command and prompts for the type of the Run
  765. to be done, selected by pressing a particular key.
  766.  
  767. Run    G  GO
  768. This  is  identical to Ctrl-R,  and resumes the program  at  full
  769. speed.
  770.  
  771. Run    I  Instruction
  772. This executes the entered number of instructions remembering
  773. information in the history buffer and then returning to monam.
  774.  
  775. Traps will be treated as single-instructions.
  776.  
  777. SEARCHING MEMORY
  778.  
  779. G                                  SEARCH MEMORY (GET A SEQUENCE)
  780. This  will  prompt Search for  B/W/L/T/I?,  standing  for  Bytes,
  781. Words, Longs, Text and Instructions.
  782.      If  you select B, W or L you will then be prompted to enter  the
  783. sequence  of numbers you wish to search for,  each  separated  by
  784. commas.  MonST is not fussy about word-alignment when  searching,
  785. so it can find longs on odd boundaries, for example.
  786.      If you select T you may search for any given text  string,  which
  787. you will be prompted for. The search will be case-dependent.
  788.      If you select I you can search for part or all of the mnemonic of
  789. an instruction,  for example if you searched for $14 (A you would
  790. find  an  instruction like MOVE.L D2,$14(A0).  The  case  of  the
  791. string you enter is important (unlike Monam version 1),  but  you
  792. should  bear in mind the format the disassembler  produces,  e.g.
  793. always use hex numbers, refer to A7 rather than SP and so on.
  794.      Having  selected  the  search type  and  parameters,  the  search
  795. begins, control passing to the Next command, described below.
  796.  
  797. N                                                       FIND NEXT
  798.      This can be used after the G command to find subsequent
  799. ccurences of the search data.  With the B,  W, L and T options you
  800. will always find at least one occurrence,  which will be in the buffer
  801. within MonAM that is used for storing the sequence.  With the  T
  802. option you may also find a copy in the system keyboard  buffer.
  803. With these options, the Esc key is tested every 64k bytes and can
  804. be used to stop the search.  With the be used to stop the search.
  805. With  the I option,  which is very much slower,  the Esc  key  is
  806. tested every 2 bytes.
  807.      The  search area of memory goes from 0 to the end of chip memory,
  808. then from $F80000 to $FFFFFF (the ROM), then any additional RAM.
  809.      The search will start just past the start address of the  current
  810. window  (except register windows) and if an occurrence  is  found
  811. re-display the window at the given address.
  812.  
  813. SEARCHING SOURCE-CODE WINDOWS
  814.      If  the  G  command is used on a source-code window  the  T  sub-
  815. command  is  automatically chosen and if the text  is  found  the
  816. window will re-display the line containing it.
  817.  
  818. MISCELLANEOUS
  819.  
  820. Ctrl-P                                                PREFERENCES
  821. This permits control over various options within MonAM. The first
  822. three require Y/N answers,  pressing Esc aborts or Return  leaves
  823. them alone.
  824.  
  825. RELATIVE OFFSETS
  826.      This  option  defaults to On and effects the disassembly  of  the
  827. address  register  indirect with offset  addressing  modes,  i.e.
  828. xxx(An).  With  the  option  on the current value  of  the  given
  829. address register is added to the offset then searched for in  the
  830. symbol table.  If found it is disassembled as symbol  (An).  This
  831. option  is  very useful for certain styles of  assembly  language
  832. programming  as  well as high level languages which  use  a  base
  833. register as a major offset, such as HiSoft BASIC which uses A3 as
  834. a pointer to the run-time system.
  835.  
  836. SYMBOLS OPTION
  837.      This  allows  control over the use of symbols in  expressions  in
  838. MonAm.  It will firstly ask whether the case of symbols should be
  839. ignored,  pressing Y will cause case independent searching to  be
  840. used.  It  will  then prompt for the maximum length  of  symbols,
  841. which is normally 32 but may be reduced to as low as 8. Or increased
  842. if required.
  843.  
  844. PRINTER DEVICE
  845.      This lets you set the device that Monam uses for its printer
  846. commands, the default is PRT:
  847.  
  848. SAVE PREFERANCES
  849.      Reply Y to this command to save your current preferances to the
  850. file monam2.inf in the current directory. When monAm2 loads it will
  851. read your current preferances from this file. Monam2.inf is firstly
  852. searched for in the current directory, then in the c: directory, in a
  853. similar way to the editor preferances file.
  854.  
  855. I                                                INTELLIGENT COPY
  856. This  copies  a block of memory to another  area.  The  addresses
  857. should be entered in the form:
  858.  
  859.         <start>,<inclusive end>,<destination>
  860.  
  861.      The copy is intelligent in that the block of memory may be copied
  862. to a location which overlaps its previous location.
  863.      NOTE:  No  checks at all are made on the validity  of  the  move;
  864. copying to non-existent areas of memory is likely to crash Monam
  865. and corrupting system areas may well crash the machine.
  866.  
  867. L                                                     LIST LABLES
  868. This opens up a large window and displays all loaded symbols. Any
  869. key displays the next page, pressing Esc aborts. The symbols will
  870. be  displayed  in the order they were found on the  disk  (or  in
  871. memory if using the Debug option from the editor).
  872.  
  873. Ctrl-U name                                        UNLOAD SYMBOLS
  874. This command can only be used if you are debugging a task which had a
  875. symbol table loaded with it. What it does is de-allocate the memory
  876. used for storing symbols, freeing it for the system to use. This can
  877. be very useful if memory is tight while debugging a lager program, as
  878. you can load it, together with symbols, set a breakpoint at a symbolic
  879. address, then lose the labels before letting it run. Of course once
  880. you hit your breakpoint you won't have any symbols.
  881.      NOTE: Thois command used to be Ctrl-L on Monam version 1.
  882.  
  883. COMMAND SUMMARY
  884.  
  885. WINDOW COMMANDS
  886. (AMIGA)-A ..................... Set Address
  887. (AMIGA)-B ..................... Set Breakpoint
  888. (AMIGA)-E ..................... Edit Window
  889. (AMIGA)-L ..................... Lock Window
  890. (AMIGA)-O ..................... Show Other
  891. (AMIGA)-P ..................... Printer Dump
  892. (AMIGA)-R ..................... Register Set
  893. (AMIGA)-S ..................... Split Windows
  894. (AMIGA)-T ..................... Change Type
  895. (AMIGA)-Z ..................... Zoom Window
  896.  
  897. BREAKPOINTS
  898. (AMIGA)-B ..................... Set Breakpoint
  899. Help ...................... Show Help and Breakpoints
  900. Ctrl-B .................... Set Breakpoint
  901. U ......................... Go Until
  902. Ctrl-K .................... Kill Breakpoints
  903. Ctrl-A .................... Set Breakpoint then Execute
  904. Ctrl-X .................... Stop program executing
  905.  
  906. LOADING AND SAVING
  907. Ctrl-L .................... Load Executable Program
  908. B ......................... Load Binary File
  909. S ......................... Save Binary File
  910. A ......................... Load ASCII File
  911.  
  912. EXECUTING PROGRAMS
  913. Ctrl-R .................... Return to program/Run
  914. Ctrl-Z .................... Single-Step
  915. Ctrl-Y .................... Single-Step
  916. Ctrl-T .................... Interpret an Instruction (Trace)
  917. Ctrl-S..................... Skip instruction
  918. R ......................... Run (various)
  919.  
  920. SEARCHING MEMORY
  921. G ......................... Search Memory (Get a sequence)
  922. N ......................... Find Next
  923.  
  924. MISCELLANEOUS
  925. Ctrl-C .................... Terminate
  926. Ctrl-Q..................... Quit program
  927. Ctrl-P .................... Preferences
  928. I ......................... Intelligent Copy
  929. W ......................... Fill Memory With
  930. L ......................... List Labels
  931. Ctrl-U..................... Unload symbols
  932. P ......................... Disassemble to Printer/Disk
  933. M ......................... Modify Address
  934. O ......................... Show Other Bases
  935. D ......................... Change Drive & Directory
  936. H ......................... Show History Buffer
  937. V.......................... View other screen
  938.  
  939. DEBUGGING STRATAGEM
  940.  
  941. RESTRICTIONS
  942.      As it runs as a process MonAm relies on the exec.intuition and
  943. graphics libraries. If your program starts destroying memory to which
  944. it has no right it is possible for it to fatally corrupt something the
  945. system needs so that when monam is entered after an exception the
  946. machine will crash. Fortuanely this type of error is rare, usually
  947. address errors occur before programs start destroying memory.
  948.      When a program is invoked from Monam it is set up to look as if
  949. it has been run from the CLI, not the workbench.
  950.      Monam cannot single step or breakpoint any code when executing in
  951. supervisor mode. This is because the exec exception handler checks for
  952. an execption in supervisor mode, amd will put up a guru alert if this
  953. is the case. If not it will enter Monam and work normally.
  954.      If your program creates another program or task you cannot use
  955. monam to breakpoint it or single-step. Monam can only debug the
  956. program that was specified when it initially loaded.
  957.      Don't try and run the standard system programs from within Monam,
  958. such as dir. These rely on undocumented registers (particually a5) and
  959. memory areas which monam cannot emulate.
  960.      Due to a hardware feature, a word - or longword-access on odd
  961. memory locations 1 to 7 inclusive will cause a complete machine crash.
  962. There seems to be nothing we can do to prevent this.
  963.  
  964. BUG HUNTING
  965.      There  are probably as many strategies for finding bugs as  there
  966. are programmers;  there is really no substitute for learning  the
  967. hard way,  by experience.  However, there are some hints which we
  968. have learnt, the hard way!
  969.      Firstly, a very good way of finding bugs is to look at the source
  970. code  and  think.  The  disadvantage of reaching  first  for  the
  971. debugger,  then second for the source code,  is that it gets  you
  972. into  bad  habits.  You may switch to a  machine  or  programming
  973. environment that does not offer low-level debugging,  or at least
  974. not one as powerful as you are used to.
  975.      If a program fails in a very detectable way,  such as causing  an
  976. exception,  debugging is normally easier than if,  say, a program
  977. sometimes doesn't quite work exactly as it should.
  978.      Many  bugs  are  caused by a  particular  memory  location  being
  979. stepped on.  Whether the offending memory location is detectable,
  980. by producing a bus error,  for example,  a conditional breakpoint
  981. placed  at  one or more main subroutines can  help  greatly.  For
  982. example, suppose the global variable main_ptr is somehow becoming
  983. odd during execution,  the conditional expression could be set up as:
  984.  
  985. (main_ptr)&1
  986.  
  987.      Count  breakpoints  are a good way of tracking down  bugs  before
  988. they occur. For example, suppose a particular subroutine is known
  989. to eventually fail but you cannot see why,  they you should set a
  990. count breakpoint on it,  then let the program run.  At the  point
  991. where the program stops, because of an exception say, look at the
  992. value  of  the  count  breakpoint  (using  Help).  Terminate  the
  993. program, re-load it, then set a stop breakpoint on the subroutine
  994. for that particular value or one before it.  Let it run, then you
  995. can  follow  through  the sub-routine on the very  call  that  it
  996. fails on, to try and work out why.                      GOOD LUCK!
  997.  
  998. EXCEPTION ANALYSIS
  999.      When an unexpected exception occurs,  it's very useful to be able
  1000. to work out where and why it occurred and,  possibly,  to  resume
  1001. execution.
  1002.  
  1003. BUS ERROR
  1004.      If the PC is in some non-existent area of memory then look at the
  1005. relevant stack to try and find a return address to give a clue as
  1006. to  the cause,  probably an unbalanced stack.  If the PC is in  a
  1007. correct  area of your program then the bus error must  have  been
  1008. caused  by a memory access to non-existent or  protected  memory.
  1009. Recovering  from bus errors and resuming execution  is  generally
  1010. not possible.
  1011.  
  1012. ADDRESS ERROR
  1013.      If  the PC is somewhere strange the method above should be  used,
  1014. otherwise the error must have been caused by a program access  to
  1015. an  odd  address.  Correcting a register value may be  enough  to
  1016. resume execution, at least temporarily.
  1017.  
  1018. ILLEGAL INSTRUCTION
  1019.      If the PC is in very low memory, below around $30, it is probable
  1020. that it was caused by a jump to location 0.  If you use MonAM to
  1021. look  here  you will normally see various ORI instructions  (really
  1022. longword   pointers)   and eventually an illegal instruction.
  1023.  
  1024. PRIVILEGE VIOLATION
  1025.      This  is  caused by executing a privileged  instruction  in  user
  1026. mode,  normally  meaning  your program has gone  horribly  wrong.
  1027. Bumping  the PC past the offending instruction is unlikely to  be
  1028. much help in resuming the program.
  1029.  
  1030. APPENDIX A: AmigaDOS error codes
  1031.      This appendix details the numeric AmegaDOS errors and their
  1032. meanings:
  1033.  
  1034. 103     insufficient free store                 out of memory
  1035. 104     task table full                         limit of 20 cli's
  1036. 120     argument line invalid or too long       when using CLI commands
  1037. 121     file is not an object module            trying to execute a non-
  1038.                                                 executable file
  1039. 122     invalid resident library during load
  1040. 202     object in use                           such as a file by another
  1041.                                                 program
  1042. 203     object already exists
  1043. 204     directory not found
  1044. 205     object not found                        most commonly a file
  1045. 206     invalid window                          in name specification
  1046. 209     packet request type unknown
  1047. 210     invalid stream component name           name too long or contains
  1048.                                                 control characters
  1049. 211     invalid object lock
  1050. 212     object not of required type             such as directory name
  1051.                                                 instead of file
  1052. 213     disk not validated                      disk is still being
  1053.                                                 validated, or is bad
  1054. 214     disk write-protected
  1055. 215     rename across devices attempted
  1056. 216     directory not empty                     when trying to delete it
  1057. 218     device not mounted                      after specifying a volume
  1058.                                                 name
  1059. 219     seek error
  1060. 220     comment too big                         file comments must be
  1061.                                                 less than 80
  1062. 221     disk full
  1063. 222     file is protected from deletion
  1064. 223     file is protected from writing
  1065. 224     file is protected from reading
  1066. 225     not a DOS disk
  1067. 226     no disk in drive
  1068. 232     no more enteries in directory
  1069.  
  1070. APPENDIX B: GenAM error messages
  1071.      Genam can produce a large number of error messages, most of which
  1072. are  pretty  self explanatory.  This appendix lists them  all  in
  1073. alphabetic  order,  with clarifications for those  which  require
  1074. them.
  1075.      Please note that GenAM is continually being improved and list may
  1076. not  agree  exactly  with the version  you  have,  there  may  be
  1077. additional messages not documented here.
  1078.  
  1079. ERRORS
  1080.      If you get a message beginning with INTERNAL please tell us - you
  1081. should never see these.
  1082.  
  1083. .W or .L expected as index size
  1084.  
  1085. absolute expression MUST evaluate
  1086.  
  1087. absolute not allowed
  1088.  
  1089. additional symbol on pass 2
  1090.             somehow a symbol has appeared during pass 2 that  did
  1091.             not appear during pass 1
  1092.  
  1093. address register expected
  1094.  
  1095. addressing mode not allowed
  1096.  
  1097. addressing mode not recognised
  1098.  
  1099. BSS or OFFSET cannot contain data
  1100.             OFFSET  sections  and non-GST BSS sections  can  only
  1101.             contain DS directives
  1102.  
  1103. cannot create a binary file
  1104.             could be a bad filename,  or a write-protected  disk,
  1105.             etc.
  1106.  
  1107. cannot export symbol
  1108.  
  1109. cannot import symbol
  1110.  
  1111. cannot reset MACRO definitions or define in REPTs
  1112.             macro definitions may not be nested or defined within
  1113.             repeat loops
  1114.  
  1115. cannot nest repeat loops
  1116.  
  1117. comma expected
  1118.  
  1119. data register expected
  1120.  
  1121. data too large
  1122.  
  1123. division by zero
  1124.  
  1125. duplicate MODULE name
  1126.  
  1127. module names must be unique
  1128.  
  1129. error during listing output
  1130.             listing will be stopped at this point
  1131.  
  1132. error during writing binary file
  1133.             normally disk full
  1134.  
  1135. executable code only
  1136.             only executable code may be assembled to memory
  1137.  
  1138. expression mismatch
  1139.             normally a syntax error within an expression
  1140.  
  1141. fatally bad conditional
  1142.             there were more ENDCs in a macro than IFs
  1143.  
  1144. file not found
  1145.  
  1146. forward reference
  1147.  
  1148. garbage following instruction
  1149.  
  1150. illegal BSR.S
  1151.             a BSR.S to the following instruction is not allowed -
  1152.             change it to BSR
  1153.  
  1154. illegal type combination
  1155.  
  1156. immediate data expected
  1157.  
  1158. imported label not allowed
  1159.  
  1160. include file read error
  1161.  
  1162. instruction not recognised
  1163.  
  1164. invalid FORMAT parameter
  1165.  
  1166. invalid INCDIR
  1167.             You have used more than 500 bytes of directory
  1168. specifications
  1169.  
  1170. invalid IF expression, ignored
  1171.  
  1172. invalid MOVEF addressing mode
  1173.  
  1174. invalid number
  1175.  
  1176. invalid numeric expression
  1177.             the  symbol  is not defined or relative or  a  syntax
  1178.             error
  1179.  
  1180. invalid option
  1181.  
  1182. invalid printer parameter
  1183.  
  1184. invalid register list
  1185.  
  1186. invalid section name, TEXT assumed
  1187.  
  1188. invalid size
  1189.  
  1190. line malformed
  1191.  
  1192. linker format restriction
  1193.             the AmigaDOS format is restrictive about where it  allows
  1194.             imports
  1195.  
  1196. local not allowed
  1197.  
  1198. missing close bracket
  1199.  
  1200. missing ENDC
  1201.             there were more IFs than ENDCs
  1202.  
  1203. missing quote
  1204.  
  1205. misuse of label
  1206.  
  1207. not yet implemented
  1208.  
  1209. number too large
  1210.  
  1211. odd address
  1212.  
  1213. option must be at start
  1214.  
  1215. ORG not allowed
  1216.  
  1217. out of memory
  1218.  
  1219. phasing error
  1220.             should  never happen,  look  investigate  immediately
  1221.             before first such error
  1222.  
  1223. program buffer full
  1224.             change  the  program buffer size when  assembling  to
  1225.             memory
  1226.  
  1227. register expected
  1228.  
  1229. relative not allowed
  1230.  
  1231. relocation not allowed
  1232.  
  1233. repeated include file
  1234.  
  1235. each include file may only be included once on each pass
  1236.  
  1237. source expired prematurely
  1238.             with an IF, MACRO or REPT and the source ran out
  1239.  
  1240. spurious ENDC
  1241.  
  1242. spurious ENDM or MEXIT
  1243.  
  1244. spurious ENDR
  1245.  
  1246. symbol defined twice
  1247.  
  1248. symbol expected
  1249.  
  1250. undefined symbol
  1251.  
  1252. user error
  1253.             caused by FAIL directive
  1254.  
  1255. wrong processor
  1256.  
  1257. XREFs not allowed within brackets
  1258.  
  1259. WARNINGS
  1260. 68010 instruction, converted to MOVE SR
  1261.             MOVE CCR, is not a 68000 instruction
  1262.  
  1263. branch made short
  1264.             by optimising
  1265.  
  1266. directive ignored
  1267.  
  1268. invalid LINK displacement
  1269.             if negative or odd
  1270.  
  1271. offset removed
  1272.             xx(An) form reduce to (An) by optimising
  1273.  
  1274. relative cannot be relocated
  1275.  
  1276. short branch converted to NOP
  1277.  
  1278. sign extended operand
  1279.             data in MOVEQ needed sign extension to fit
  1280.  
  1281. size should be .W
  1282.  
  1283. APPENDIX C: CALLING THE OPERATING SYSTEM
  1284.  
  1285. INTRODUCTION
  1286.      The Amiga operating system is arguably with the exception of OS/2
  1287. the most sophisticated of any mass produced computer, and is also the
  1288. most complicated. The whole machine is based around the concept of
  1289. libraries, which are essentially groups of subroutones (or functions
  1290. to C-programmers) indexed off a large jump block. The appendix is
  1291. intended to explain the basics of calling libraries from assembly
  1292. language, and to give an idea of what each can be used for. One small
  1293. Appendix cannot possibly describe the whole operating system, it is
  1294. only meant as an introduction.
  1295.     Please note that was written with version 1.2 of Kickstart in
  1296. mind, it is possible subsiquent versions may differ slightly. Any
  1297. important differances should be detailed in the readme file.
  1298.  
  1299. LIBRARIES
  1300.      The most basic library is the exec library, which has to be
  1301. called to open nay other library, among other things. As with all
  1302. libraries, a library base pointer is required to access it, and this
  1303. must be loaded into register a6 before calling any function. The exec
  1304. library is unique as that it dosen't have to be opened to obtain a
  1305. base pointer - this can be obtained from the longword at location 4 -
  1306. the only location in the whole machine guaranteed to remain the same
  1307. in the future. The base pointer so obtained can then be used to open
  1308. further libraties, to obtain other library base pointers, and so on.
  1309. Note that most libraries require a6 to be contained in the base
  1310. pointer for correct operation (as they call the other routines in the
  1311. same library) though not all do. Parimiters are passed to library
  1312. routines in requesters, and sa a general rule requesters d0/d1/a0/a1
  1313. should be assumed to be corrupted by any call.
  1314.      A large number of include files are supplied with DEVPAC to allow
  1315. easy access to the various parts of the opearting system. These
  1316. include files containing macro definitions, library offset symbols,
  1317. data structure definitions, and bit field symbols. There now follows a
  1318. library table showing the names of the various components, and where
  1319. the definitions can be found in the include directory.
  1320.  
  1321. FILE: this shows the file that contains the macro definitions and _LVO
  1322. offsets for calling the library.
  1323.  
  1324. NAME MACRO: this normally consists of a dc.b statement defining the
  1325. ASCII for the name, ending in a null.
  1326.  
  1327. BASE POINTER: this is the symbolic name of the longword used for
  1328. storing the base pointer. It always starts with an underline
  1329. character, though when used from most C compilers this underline is
  1330. not shown.
  1331.  
  1332. CALLING MACRO: this is the name of the macro that calls a particular
  1333. library. Note that this will corrupt register a6 as it will be loaded
  1334. with the relevant library base pointer.
  1335.  
  1336. LIBRARY         FILE                            NAME MACRO
  1337.                         BASE POINTER                    CALLING MACRO
  1338. diskfont        libraries/diskfont_lib.i        DISKFONTNAME
  1339.                         _DiskfontBase                   CALLDISKFONT
  1340. dos             libraries/dos_lib.i             DOSNAME *
  1341.                         _DOSBase                        CALLDOS
  1342. exec            exec/exec_lib.i                 EXECNAME
  1343.                         _SysBase                        CALLEXEC
  1344. expansion       libraries/expansion_lib.i       EXPANSIONNAME **
  1345.                         _ExpansionBase                  CALLEXP
  1346. graphics        grapgics/graphics_lib.i         GRAFNAME
  1347.                         _GfxBase                        CALLGRAF
  1348. icon            workbench/icon_lib.i            ICONNAME
  1349.                         _IconBase                       CALLICON
  1350. intuition       intuition/intuition_lib.i       INTNAME
  1351.                         _IntuitionBase                  CALLINT
  1352. mathffp         math/mathffp_lib.i              FFPNAME
  1353.                         _MathBase                       CALLFFP
  1354. mathdouble      math/mathieeedoubas_lib.i       IEEEDOUBNAME
  1355.                         _MathIeeeDouBasBase             CALLIEEEDOUB
  1356. mathtrans       math/mathtrans_lib.i            MATHTRANSNAME
  1357.                         _MathTransBase                  CALLMATHTRANS
  1358. translator      libraries/translator_lib.i      TRANSNAME
  1359.                         _TranslatorBase                 CALLTRANS
  1360.  
  1361.      For example, to call the exec library function OpenLibrary
  1362. suitable assembler source code would be
  1363.  
  1364.         CALLEXEC    OpenLibrary
  1365.  
  1366. This macro is expanded into
  1367.  
  1368.         move.l      (_SysBase).w,a6
  1369.         jsr         _LVOOpenLibrary(a6)
  1370.  
  1371.  * = name macro definition can be found in file libraries/dos.i
  1372. ** = mane macro can be found in file libraries/expansion.i
  1373.  
  1374. DISKFONT LIBRARY:
  1375.      This is a library for handling fonts that are normally resident
  1376. on the disk.
  1377. FILES: libraries/diskfont.i and diskfont_lib.i
  1378.  
  1379. DOS LIBRARY:
  1380.      One of the most straightforward of the libraries to use, this
  1381. handles file i/o (input/output) to devices, including disk and
  1382. console. It has some slight anomalities, notabily addersses have to be
  1383. passed in data registers, and many pointers have to be BCPL-type (ie.
  1384. longword aligned and divided by 4)
  1385. FILES: libraries/dos.i  dos_lib.i and dosextens
  1386.  
  1387. EXEC LIBRARY:
  1388.      This is the lowest level of library, responsible for things like
  1389. memory management, library calls, and message passing. The library
  1390. never has to be opened - its base pointer is contained in location 4.
  1391. FILES: exec/ables.i  alerts.i  devices.i  errors.i  exec.i  execbase.i
  1392. execname.i  exec_lib.i  funcdef.i  initializers.i  interrupts.i  io.i
  1393. libraries.i  lists.i  memory.i  nodes.i  ports.i  resident.i
  1394. strings.i  tasks.i  and types.i
  1395.  
  1396. GRAPHICS LIBRARY:
  1397.      This is responsible for controlling exectly what appears on your
  1398. monitor, including things like drawing lines, printing text,
  1399. controlling RastPorts, sprite handling and fonts.
  1400. FILES: graphics/clip.i  copper.i  display.i  gels.i  gfx.i  gfxbase.i
  1401. graphics_lib.i  layers.i  rastport.i  regions.i  sprite.i  text.i  and
  1402. view.i
  1403.  
  1404. ICON LIBRARY:
  1405.      This library is responsible for handling the icons displayed by
  1406. the Workbench.
  1407. FILES: workbench/icon.i  icon_lib.i
  1408.  
  1409. INTUITION LIBRARY:
  1410.      This library is the lagest and is responsible for the windowing
  1411. intuition user interface. It has a very large number of functions,
  1412. including those for window conrtol, screens. gadgets, requesters, and
  1413. event handling.
  1414.      The main file is large and also includes a large number of other
  1415. files, so don't be surprised if it takes a little while to read it
  1416. all. It can be worthwile to create your own specilised version without
  1417. the less-often used constants, which can reduce the amount of other
  1418. include files required.
  1419. FILES: intuition/intuition.o  and intuition_lib.i
  1420.  
  1421. MATHS LIBRARIES:
  1422.      There are three maths libraries, all based on the official
  1423. Motorola routines. The FFP (Fast Floating Point) library uses an 8-bit
  1424. exponent, 24-bit mantissa format. The format used was designed for the
  1425. 68000 series, and is exclusive to Motorola. The IEEE double library
  1426. offers doublr-precision using IEEE standard formats for numbers, and
  1427. the Trancendental library is used for FFP trig and other functions.
  1428. FILES: math/mathffp_lib.i  mathieeedoubbas_lib.i  and  mathtrans_lib.i
  1429.      As a genaral rule you should use GenAm in case sensative mode
  1430. (the default) when using the supplied include files. note that every
  1431. include file always includes any others it needs automatically, so you
  1432. don't need to worry about it.
  1433.  
  1434. EXAMPLE PROGRAMS
  1435.     To help you get started programming AmigaDOS from assembly
  1436. language we have provided the source to a few example programs in the
  1437. examples directory.
  1438.  
  1439. DEMO.S
  1440.      this is the program used for the tutorial at the beginning of the
  1441. manual. It uses the DOS library to print a message on the current CLI
  1442. window.
  1443.  
  1444. FREEMEM.S
  1445.     This program that uses intuition to create a window in which the
  1446. system free memory is constantly displayed, until the close gadget is
  1447. clicked on. To run this concurrently from the CLI use the command:
  1448.  
  1449. run examples/freemem
  1450.  
  1451. HELLOWORLD.S
  1452.      This is the assembly language conversion of the C program 'final
  1453. version of the simple program' described at the beginning of
  1454. 'intuition - the amiga user interface'. The conversion has not been
  1455. optimised in any way, for example, the structure assignment for
  1456. NewScreen would be more efficient using dc.w/dc.l statements, but has
  1457. been left as MOVE instructions for a more accurate conversion. The
  1458. program opens up a custom screen and, within it, a simple message.
  1459.  
  1460. CLI vs WORKBENCH
  1461.      There are two program enviroments on the amiga - the windows &
  1462. icon driven workbench, and the CLI. Devpac itself runs only under the
  1463. latter, as do most example programs, the differance being in the
  1464. startup and exit code.
  1465.  
  1466. CLI STARTUP
  1467.      When a program is run from the CLI it starts with register a0
  1468. containing the address of the command linem and d0 containing its
  1469. length. The DOS handles returned by input and output can be used for
  1470. i/o with the console device, and to exit the program should simply
  1471. RTS.
  1472.  
  1473. WORKBENCH STARTUP
  1474.      When a program is run from the Workbench it has to wait firstly
  1475. for a message, and on terminating it has to reply to the message
  1476. (after doing a forbid call) before RTSing. The DOS functions input and
  1477. output will not return valid handles, so you need to open a window to
  1478. perform any console i/o
  1479.      the startup differances are detailed in part 4, chapter 2 of the
  1480. ROM Kernal Menual Volume 1, together with the assembly language source
  1481. of the startup code used by C programs. Note that there is a bug in it
  1482. - the routine openDOS should have a moveq #0,d0 instruction added
  1483. before the call to OpenLibrary, otherwise a fatal alert can be
  1484. produced.
  1485.      A skeleton version of this for assembly language programmers can
  1486. be found in the file misc/easystart.i which is included by the
  1487. freemem2.s example program. It should be included at the very front of
  1488. your programs, and handles the message-passing to allow programs to be
  1489. run from workbench. Of course to do this you will need to create an
  1490. icon for your program, using iconed.
  1491.  
  1492. APPENDIX D: USING THE CLI
  1493.      All this section is covered in the Amiga manuals you get with the
  1494. machine so look them up yourselves!
  1495.  
  1496. APPENDIX E: CONVERTING FROM OTHER ASSEMBLERS
  1497.      Most 68000 assemblers for the Amiga follow, to one degree or
  1498. another the Motorola standard. While the instructions themselves  are
  1499. thankfully standard,  the syntax rules for labels,  comments  and
  1500. directives can,  and do,  vary.  This Appendix covers the changes
  1501. most  likely  to be made when converting  programs  from  another
  1502. assembler,  whether  they are your old source files or a  program
  1503. listed  in  a  magazine.  It  does  not  attempt  to  detail  the
  1504. differences  in user interfaces or options between the  different
  1505. assemblers.
  1506.  
  1507. AMIGA MACRO ASSEMBLER AND MCC ASSEMBLER:
  1508.      Almost all source code written for assembly under the Amigados
  1509. Macro Assembler supplied by Commodore and the Metacomco (MCC)
  1510. assembler should assemble with little or no change under GenAm. The
  1511. differances are:
  1512.  
  1513. 1. With GenAm, importing constants using XREF and then accessing them
  1514. as constants (as opposed to relative addresses) may cause warning
  1515. messages. Many source programs use XREFs for _LVO labels. To remove
  1516. these warnings either:
  1517.  
  1518. change XREF to XREF.l
  1519. use OPT W- to supress all warnings
  1520. use OPT T- to suppress type-checking
  1521. include the relevant _lib.l file and remove the XREF
  1522.  
  1523. 2. The directive RORG is not supported. The include files with the
  1524. AmigaDOS Macro Assembler will assemble unchanged by GenAm, but our
  1525. supplied ones are preferred because they use directives instead of
  1526. macro calls to define labels and have comments removed to take less
  1527. disk space and be faster to assemble. The original versions can be
  1528. found in Appendix E of ROM Kernal Manual Volume 2 and on DEVPAC disk
  1529. 2.
  1530.  
  1531. K-SEKA:
  1532.      Colons are not required after labels in GenAm though instructions
  1533. or directives that start in the label field will need a tab added
  1534. before them.  Several Seka directives default to Byte instead  of
  1535. Word sizes for some reason. Equivalent directives names are:
  1536.  
  1537. D=DC,  BLK=DS,  IF=IFNE,  ELSE=ELSEIF, ENDIF=ENDC.
  1538.  
  1539. Macro syntax requires ?s to be changed to \s, except ?0 which should
  1540. be replaced with \@.
  1541.  
  1542. NEW COMMODORE INCLUDE FILES
  1543.      Should you obtain new include files from Commodore you should be
  1544. able to assemble them unchanged with GenAm. however should you wish to
  1545. convert them to the same form as those supplied by us so that they
  1546. take less disk space, and assemble faster, we have supplied two tools
  1547. to convert them for you, 'convertFD' and 'convertI'
  1548.  
  1549. CONVERTI DETAILS:
  1550.      Converti is supplied on disk 2 and converts Commodore include
  1551. files to the same compressed form that we supply. The commandline is
  1552. of the form:
  1553.  
  1554. ConvertI (source) (destination) <-d>
  1555.  
  1556.      The source and destination file names should have their extension
  1557. omitted. Teh -d flag indicates that a whole directory is to be
  1558. converted. For example:
  1559.  
  1560. ConvertI old/dos new/dos
  1561.  
  1562. converts the single file old/dos.i to new/dos.i
  1563.  
  1564. ConvertI old new -d
  1565.  
  1566. will convert all the standard files in the directory old (of course
  1567. they must be there first) to the corresponding name in the directory
  1568. new.
  1569.  
  1570. CONVERTFD DETAILS:
  1571.      ConvertFD is supplied on disk 2 and converts Commodore FD files
  1572. into library files with extension _lib.i containing the_LVO offsets
  1573. for inclusion into your programs.
  1574.      The command-line is of the form:
  1575.  
  1576. ConvertFD (source) (destination) <-d)
  1577.  
  1578.      The source and destination file names should have their
  1579. extensions onitted. The -d flag indicates that a whole directory is to
  1580. be converted. For example:
  1581.  
  1582. ConvertFD fdfiles/dos new/dos
  1583.  
  1584. converts the single file fdfiles/dos_lib.fd to new/dos_lib.i
  1585.  
  1586. ConvertFD fdfiles :include/libraries -d
  1587.  
  1588. will convert all the fd files in the directory fdfiles (of coures they
  1589. must be there first) to the corrosponding include file in the
  1590. directory :include/libraries.
  1591.  
  1592. APPENDIX F: VERSION 2 IMPROVEMENTS
  1593.      All information is already documented earlier.
  1594.  
  1595. APPENDIX G: BIBLIOGRAPHY
  1596.      This bibliography contains our suggestions for further reading on
  1597. the subject of the 68000 and the Amiga.  The views expressed
  1598. are  our  own  and  as  with all  reference  books  there  is  no
  1599. substitute  for  looking at the books in a good  bookshop  before
  1600. making a decision.
  1601.  
  1602. M68000 Programmer's Reference Manual
  1603. Published by Prentice-Hall
  1604. The definitive guide to the instruction set produced by Motorola.
  1605. the  supplied Pocket Guide is a subset of this book.  Be sure  to
  1606. get the latest version - at the time of writing the Fifth Edition
  1607. is the latest.
  1608.  
  1609. 68000 Assembly Language Programming by Kane, Hawkins & Leventhal
  1610. Published by Osborne/McGraw-Hill
  1611. This  is  large  (and expensive) but  good,  containing  lots  of
  1612. examples.  Be  sure to get the second edition.  Not for  complete
  1613. beginners to microprocessors.
  1614.  
  1615. 68000 Tricks and Traps by Mike Morton
  1616. BYTE magazine, September 1986 issue
  1617. By  far the best article on 68000 programming we have ever  seen.
  1618. We wish there was a book like this.
  1619.  
  1620. M68000 Cross Macro Assembler Reference Manual
  1621. Published by Motorola (M68KXASM)
  1622. The  official  definition of 68000  assembly-language  syntax  on
  1623. which Genam is based.
  1624.  
  1625. APPENDIX H: TECHNICAL SUPPORT AND UPGRADES
  1626.       Which is no use to you as your not a registered user!.
  1627.